//
//  TCOptionCell.m
//  陶瓷
//
//  Created by 王戈 on 15/8/14.
//  Copyright (c) 2015年 王戈. All rights reserved.
//

#import "TCOptionCell.h"
#import "OptionView.h"

@interface TCOptionCell ()
@property (nonatomic, strong) OptionView *optionView;

@end


@implementation TCOptionCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *identifier = @"TCOptionCell";
    
    TCOptionCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[TCOptionCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.font = [UIFont systemFontOfSize:14];
        cell.textLabel.textAlignment = NSTextAlignmentRight;
    }
    return cell;
}

- (void)setOptions:(NSArray *)options {
    _options = options;
    _optionView = [OptionView optionViewWithArray:options];
//    _optionView.selectedOptions = [_selectedOptions mutableCopy];
    _optionView.option = options.firstObject;
    [self.contentView addSubview:_optionView];
    [self layoutIfNeeded];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    float mer = (self.width - 25) * 0.33;
    self.textLabel.frame = CGRectMake(0, 0, mer, self.height);
    self.optionView.frame = CGRectMake(mer, 0, 2 * mer, self.height);
}
@end
